/*
 * @copyright 2010 Gerald Jacobson
 * @license GNU General Public License
 * 
 * This file is part of Descent Assistant.
 *
 * Descent Assistant is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Descent Assistant is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Descent Assistant.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.amphiprion.descenttool.entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @author Amphiprion
 * 
 */
public class Monster implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public enum AttackType {
		MELEE, RANGE, MAGIC, MORPH
	}

	public String name;
	public String image;
	public String clazz;
	public String extend;
	public String level;
	public String id;
	public AttackType attackType = AttackType.MORPH;

	private int moveStart;
	private int healthStart;
	private int armorStart;

	private int move;
	private int health;
	private int armor;

	public boolean major;
	public int diceWhite;
	public int diceBlue;
	public int diceRed;
	public int diceGreen;
	public int diceYellow;
	public int diceBlack;
	public int diceSilver;
	public int diceGold;
	public int diceMorph;

	private List<Skill> skills = new ArrayList<Skill>();

	public Monster(int move, int health, int armor) {
		this.move = move;
		this.health = health;
		this.armor = armor;

		moveStart = move;
		healthStart = health;
		armorStart = armor;
	}

	public int getArmor() {
		return armor;
	}

	public void setArmor(int armor) {
		this.armor = armor;
	}

	public int getHealth() {
		return health;
	}

	public void setHealth(int health) {
		this.health = health;
	}

	public int getMove() {
		return move;
	}

	public void setMove(int move) {
		this.move = move;
	}

	public void reinit() {
		move = moveStart;
		health = healthStart;
		armor = armorStart;
	}

	public void setMoveStart(int moveStart) {
		this.moveStart = moveStart;
		move = moveStart;
	}

	public void setHealthStart(int healthStart) {
		this.healthStart = healthStart;
		health = healthStart;
	}

	public void setArmorStart(int armorStart) {
		this.armorStart = armorStart;
		armor = armorStart;
	}

	public List<Skill> getSkills() {
		return skills;
	}

	public void removeSkill(String skillId) {
		Skill s = null;
		for (Skill skill : skills) {
			if (skill.id.equals(skillId)) {
				s = skill;
				break;
			}
		}
		if (s != null) {
			skills.remove(s);
		}
	}

	public Skill addSkill(Skill newSkill) {
		for (Skill skill : skills) {
			if (skill.id.equals(newSkill.id)) {
				skill.setValue(skill.getValue() + newSkill.getValue());
				return skill;
			}
		}
		skills.add(newSkill);
		return newSkill;
	}
}
